package com.aaa.sbm.controller;

import com.aaa.sbm.entity.StockInDetail;
import com.aaa.sbm.service.StockInService;
import com.aaa.sbm.util.Page;
import com.aaa.sbm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("stockIn")
public class StockInController {
    @Resource
    private StockInService stockInService;

    @GetMapping("")
    public String index() {
        return "html/stocke";
    }

    @RequestMapping("insertSatockIn")
    public Result insertSatockIn(@RequestBody StockInDetail stockInDetail) {
        return stockInService.insertStockInDetailIn(stockInDetail);
    }

    @PostMapping("list")
    public Result list(@RequestBody(required = false) Page<StockInDetail> stockInDetail) {
        return stockInService.getStockList(stockInDetail);
    }

    @PutMapping("update")
    public Result update(@RequestBody(required = false) StockInDetail stockInDetail) {
        return stockInService.updateStockIn(stockInDetail);
    }

    @GetMapping("delete/{inId}")
    public Result delete(@PathVariable Integer inId) {
        return stockInService.deleteStockIn(inId);
    }

    @PutMapping("/batch")
    public Result batchStockIn(@RequestBody List<StockInDetail> stockInDetails) {
        return stockInService.batchStockIn(stockInDetails);
    }
}
